<!DOCTYPE html>
<html lang="en">
<head>
    <meta charset="UTF-8">
    <meta http-equiv="X-UA-Compatible" content="IE=edge">
    <meta name="viewport" content="width=device-width, initial-scale=1.0">
    <title>Document</title>
    
</head>
<body>
    <script>
        //1.获取元素
        // 百度里面的img
        var imgs=document,querySelector(".baidu").querySelector('img');
        //2.循环注册事件
        for(var i=0;i<imgs.length;i++){
            imgs[i].onclick=function(){
                // this.src就是我们点击图片的路径
                document.body.style.backgroundImage=url'("+this.src+")';

            }
        }
    </script>
</body>
</html>